﻿using UnityEngine;
using System.Collections.Generic;
namespace Dict.Blo
{ 
    public class DictUnionFightTowerBlo
    {
        static public List<Dict.DataModel.TableUnionFightTower> GetAll()
        {
            return Dict.DictDataManager.Instance.tableUnionFightTowerDao.CacheList;
        }

        static public Dict.DataModel.TableUnionFightTower GetTowerByID(string id)
        {
            return Dict.DictDataManager.Instance.tableUnionFightTowerDao.GetById(id);
        }

   

        static public Vector3 GetPosition(string id)
        {
            var pos = GetTowerByID(id);
            if (!string.IsNullOrEmpty(pos.Position))
            {
                var sss = pos.Position.Trim().Split(new char[1] { ',' }, System.StringSplitOptions.RemoveEmptyEntries);

                var x = float.Parse(sss[0]);
                var y = float.Parse(sss[1]);
                var z = float.Parse(sss[2]);

                return new Vector3(x, y, z);
            }
            else
            {
                return Vector3.zero;
            }
        }
        static public Vector3 GetFirePoint(string id)
        {
            var pos = GetTowerByID(id);
            if (!string.IsNullOrEmpty(pos.FirePoint))
            {
                var sss = pos.FirePoint.Trim().Split(new char[1] { ',' }, System.StringSplitOptions.RemoveEmptyEntries);
                var x = float.Parse(sss[0]);
                var y = float.Parse(sss[1]);
                var z = float.Parse(sss[2]);
                return new Vector3(x, y, z);
            }
            else
            {
                Debug.Log("[ERROR] fire point is error!");
            }
        
            return Vector3.zero;
        }
    }
}